<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>灯泡开关05</title>
    <style>
        .box{
            margin: 10px auto;
            text-align: center;
        }
        button{
            outline: none;
            cursor: pointer;
            border-radius: 15px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <div class="box">
        <button type="button">开启</button><br/>
        <img src="img/pic_bulbon.gif" alt="">
        <!-- <img src="img/pic_bulboff.gif" alt=""> -->
    </div>
</body>
<script>
    var btn = document.querySelector('button');
    var imgs = document.querySelector('img');
    btn.onclick = function(){
        if(btn.innerHTML == '开启'){
            imgs.src = 'img/pic_bulboff.gif';
            btn.innerHTML = '关启';
            btn.style.background = 'rgb(0,254,255)'
        }else{
            imgs.src = 'img/pic_bulbon.gif';
            btn.innerHTML = '开启';
            btn.style.background = 'rgb(88,24,255)'
        }
    }
</script>
</html>